package com.sefonsoft.dataanalysis.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.sefonsoft.dataanalysis.dao.CommonMapper;

@RequestMapping("user")
@RestController
public class TestWeb {
//	@Autowired
//	private SiteMapper userMapper;
	@Autowired
	private CommonMapper commonMapper;
	
//	@GetMapping("/list/all")
//	public List<Site> listAll() {
//		return userMapper.query();
//	}
//	
	@GetMapping("/test")
	public String test() {
		return "success";
	}
	
	@GetMapping("/createTableTest")
	public String createTest(String tableName) {
		 String res = "";
		 int i = commonMapper.existTable(tableName);
		 if (i == 0) {
			 res = "表不存在 ";
			 commonMapper.createTmpTable("create table "+tableName+"(name varchar(50),value varchar(50),age varchar(50)) ENGINE=MEMORY DEFAULT CHARSET=utf8");
		 } else {
			 res = "表存在 ";
			 commonMapper.dropTable(tableName);
			 res = "表删除成功 ";
			 commonMapper.createTmpTable("create table "+tableName+"(name varchar(50),value varchar(50),age varchar(50)) ENGINE=MEMORY DEFAULT CHARSET=utf8");
		 }
		 return res+"创建成功";
	}
}
